package cn.tedu.stage2.reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要加载的类的名字:");
        String className = scanner.nextLine();
        Class cls = Class.forName(className);
        String name = cls.getName();
        // 获取包名、类名
        System.out.println(name);

        // 仅获取类名
        String simpleName = cls.getSimpleName();
        System.out.println(simpleName);

        String packageName = cls.getPackage().getName();
        System.out.println("包名"+packageName);

        Method[] methods = cls.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
        }


    }
}
